﻿<Window x:Class="VMWorkshop.Wpf.Views.Demo"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dg="clr-namespace:Microsoft.Windows.Controls;assembly=WpfToolkit"
    Title="Demo" Height="462" Width="400">
    <StackPanel>
        <StackPanel HorizontalAlignment="Left">
            <dg:DataGrid x:Name="productGrid" 
                         SelectionMode="Single"
                         ItemsSource="{Binding Products}"
                         SelectionChanged="productGrid_SelectionChanged"
                         AutoGenerateColumns="False">
                <dg:DataGrid.Columns>
                    <dg:DataGridTextColumn Header="Title" Binding="{Binding Title}" />
                    <dg:DataGridTextColumn Header="Description" Binding="{Binding Description}" />
                    <dg:DataGridTextColumn Header="Qty" Binding="{Binding QuantityOnHand}" />
                </dg:DataGrid.Columns>
            </dg:DataGrid>
        </StackPanel>
        <Grid x:Name="editGrid" Margin="5" Visibility="{Binding EditFormVisibility}">
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="100" />
                <ColumnDefinition Width="200" />
            </Grid.ColumnDefinitions>

            <TextBlock Text="Title" Grid.Column="0" Grid.Row="0" />
            <TextBlock Text="Description" Grid.Column="0" Grid.Row="1" />
            <TextBlock Text="Qty" Grid.Column="0" Grid.Row="2" />
            <TextBlock Text="Release Date" Grid.Column="0" Grid.Row="3" />
            <TextBlock Text="Price" Grid.Column="0" Grid.Row="4" />

            <TextBox Grid.Column="1" Grid.Row="0" Text="{Binding Path=SelectedProduct.Title, Mode=TwoWay}" />
            <TextBox Grid.Column="1" Grid.Row="1" Text="{Binding Path=SelectedProduct.Description, Mode=TwoWay}" />
            <TextBox Grid.Column="1" Grid.Row="2" Text="{Binding Path=SelectedProduct.QuantityOnHand, Mode=TwoWay}" />
            <TextBox Grid.Column="1" Grid.Row="3" Text="{Binding Path=SelectedProduct.ReleaseDate, Mode=TwoWay}" />
            <TextBox Grid.Column="1" Grid.Row="4" Text="{Binding Path=SelectedProduct.Price, Mode=TwoWay}" />

            <Button x:Name="saveButton" Grid.Column="1" Grid.Row="5" Content="Save" Click="saveButton_Click" />

        </Grid>
        <StackPanel x:Name="updateMsg" Margin="5" Visibility="{Binding UpdateMessageVisibility}">
            <TextBlock Text="Your changes are saved." />
        </StackPanel>
    </StackPanel>
</Window>
